

/* Model */

WindLinkModel = function() {
	
}

WindLinkModel.prototype.setId = function (id) {
	this.id = id;
}

WindLinkModel.prototype.getId = function () {
	return this.id;
}

WindLinkModel.prototype.setText = function (text) {
	this.text = text;
}

WindLinkModel.prototype.getText = function () {
	return this.text;
}

WindLinkModel.prototype.setURL = function (url) {
	this.url = url;
}

WindLinkModel.prototype.getURL = function () {
	return this.url;
}

/* View */

var WindLink = new Object();

WindLink.createViewFromIdText = function(id, text) {
	var linkModel = new WindLinkModel();
	linkModel.setId(id);
	linkModel.setText(text);
	
	var linkView = WindLink.createView(linkModel);
	return linkView;
}

WindLink.createViewFromIdTextURL = function(id, text, url) {
	var linkModel = new WindLinkModel();
	linkModel.setId(id);
	linkModel.setText(text);
	linkModel.setURL(url);
	
	var linkView = WindLink.createView(linkModel);
	return linkView;
}

WindLink.createView = function(linkModel) {
	
	var linkView = new WindView;
	linkView.setCssClass("WindLink");
	
	var id = linkModel.getId(); 
	if(id!=null) {
		linkView.setId(id);
	}
	
	var text = linkModel.getText(); 
	if(text!=null) {
		linkView.setText(text);
	}
	
	var url = linkModel.getURL();
	linkView.createHtmlElement = function() {
		var a = document.createElement("a");
		
		if(url!=null) {
			a.href = "?" + url;
		} else {
			a.href = "#";
		}
		
		return a;
	}

	linkView.onClick = linkModel.onClick;

	return linkView;
}

